//
//  RegisteredViewController.m
//  AAIM
//
//  Created by 远的小布丁 on 2019/12/2.
//  Copyright © 2019 AAIM. All rights reserved.
//

#import "RegisteredViewController.h"

@interface RegisteredViewController ()<UITextFieldDelegate,UIGestureRecognizerDelegate,UIActionSheetDelegate,UINavigationControllerDelegate,UIImagePickerControllerDelegate>
//@property (nonatomic,strong)UIButton * backBtn;
@property (nonatomic,strong) UIImageView * userHeaderImageView;
@property (nonatomic,strong) UILabel * updataImage;
@property (nonatomic,strong) UITextField * nickNameTF;
@property (nonatomic,strong) UIButton * sexManBtn;
@property (nonatomic,strong) UIButton * sexWomanBnt;
@property (nonatomic,strong) UITextField * accountTF;
@property (nonatomic,strong) UITextField * passwordTF;
@property (nonatomic,strong) UITextField * againPasswordTF;
@property (nonatomic,strong) UITextField * inviteTF;
@property (nonatomic,strong) UIButton * rgeisterBtn;
@property (nonatomic,strong) NSString * isMan;//0男，1女，2未选择
@property (nonatomic,strong) NSString * imageStr;
@property (nonatomic,strong) NSString * temToken;
@end

@implementation RegisteredViewController

- (void)viewDidLoad {
    [super viewDidLoad];
 
//    [self.view addSubview:self.backBtn];
    [self.view addSubview:self.userHeaderImageView];
    [self.view addSubview:self.updataImage];
    [self.view addSubview:self.nickNameTF];
    [self.view addSubview:self.sexManBtn];
    [self.view addSubview:self.sexWomanBnt];
    [self.view addSubview:self.accountTF];
    [self.view addSubview:self.passwordTF];
    [self.view addSubview:self.againPasswordTF];
    [self.view addSubview:self.inviteTF];
    [self.view addSubview:self.rgeisterBtn];
    _isMan = @"2";
    [self setUI];
}

- (void)viewWillAppear:(BOOL)animated{
    self.gk_navigationBar.gk_navLineHidden = YES;
}

- (void)BackActive:(UIButton *)sender{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)setUI{
//    [_backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.view.mas_left).offset(15.f);
//        make.top.equalTo(self.view.mas_top).offset(34.f);
//        make.size.mas_equalTo(CGSizeMake(35.f, 40.f));
//    }];
    
    [_userHeaderImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.equalTo(self.view.mas_top).offset(66.f);
        make.size.mas_equalTo(CGSizeMake(98.f,98.f));
    }];
    [_updataImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.equalTo(self.userHeaderImageView.mas_bottom).offset(14.f);
    }];
    [_nickNameTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(SCALAE_WIDTH(34.f));
        make.top.equalTo(self.updataImage.mas_bottom).offset(31.f);
        make.right.equalTo(self.view.mas_right).offset(SCALAE_WIDTH(-34.f));
        make.height.offset(45.f);
    }];
    
    UIView * line = [UIView new];
    line.backgroundColor = KHEXCOLOR(@"#E0E0E0");
    
    [self.view addSubview:line];

    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(SCALAE_WIDTH(34.f));
        make.top.equalTo(self.nickNameTF.mas_bottom);
        make.right.equalTo(self.view.mas_right).offset(SCALAE_WIDTH(-34.f));
        make.height.offset(0.5f);
    }];

    [_sexManBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(SCALAE_WIDTH(34.f));
        make.top.equalTo(line.mas_bottom).offset(5.f);
        make.size.mas_equalTo(CGSizeMake(SCALAE_WIDTH(45.f), SCALAE_WIDTH(45.f)));
    }];
    
    [_sexWomanBnt mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.sexManBtn.mas_right).offset(SCALAE_WIDTH(78.f));
        make.top.equalTo(line.mas_bottom).offset(5.f);
        make.size.mas_equalTo(CGSizeMake(SCALAE_WIDTH(45.f), SCALAE_WIDTH(45.f)));
    }];

    UIView * line1 = [UIView new];
    line1.backgroundColor = KHEXCOLOR(@"#E0E0E0");
    
    [self.view addSubview:line1];
        [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view.mas_left).offset(SCALAE_WIDTH(34.f));
            make.right.equalTo(self.view.mas_right).offset(SCALAE_WIDTH(-34.f));
            make.top.equalTo(self.sexManBtn.mas_bottom);
            make.height.offset(0.5f);
        }];
    [_accountTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(SCALAE_WIDTH(34.f));
        make.top.equalTo(line1.mas_bottom).offset(5.f);
        make.right.equalTo(self.view.mas_right).offset(SCALAE_WIDTH(-34.f));
        make.height.offset(45.f);
    }];
    UIView * line2 = [UIView new];
    line2.backgroundColor = KHEXCOLOR(@"#E0E0E0");
    
    [self.view addSubview:line2];
    [line2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(SCALAE_WIDTH(34.f));
        make.right.equalTo(self.view.mas_right).offset(SCALAE_WIDTH(-34.f));
        make.top.equalTo(self.accountTF.mas_bottom);
        make.height.offset(0.5f);
    }];
    
    [_passwordTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(SCALAE_WIDTH(34.f));
        make.top.equalTo(line2.mas_bottom).offset(5.f);
        make.right.equalTo(self.view.mas_right).offset(SCALAE_WIDTH(-34.f));
        make.height.offset(45.f);
    }];
    
    UIView * line3 = [UIView new];
    line3.backgroundColor = KHEXCOLOR(@"#E0E0E0");
    
    [self.view addSubview:line3];
    [line3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(SCALAE_WIDTH(34.f));
        make.right.equalTo(self.view.mas_right).offset(SCALAE_WIDTH(-34.f));
        make.top.equalTo(self.passwordTF.mas_bottom);
        make.height.offset(0.5f);
    }];
    
    [_againPasswordTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(SCALAE_WIDTH(34.f));
        make.top.equalTo(line3.mas_bottom).offset(5.f);
        make.right.equalTo(self.view.mas_right).offset(SCALAE_WIDTH(-34.f));
        make.height.offset(45.f);
    }];
    UIView * line4 = [UIView new];
    line4.backgroundColor = KHEXCOLOR(@"#E0E0E0");
    
    [self.view addSubview:line4];
    [line4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(SCALAE_WIDTH(34.f));
        make.right.equalTo(self.view.mas_right).offset(SCALAE_WIDTH(-34.f));
        make.top.equalTo(self.againPasswordTF.mas_bottom);
        make.height.offset(0.5f);
    }];
    
    [_inviteTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(SCALAE_WIDTH(34.f));
        make.top.equalTo(line4.mas_bottom).offset(5.f);
        make.right.equalTo(self.view.mas_right).offset(SCALAE_WIDTH(-34.f));
        make.height.offset(45.f);
    }];
    UIView * line5 = [UIView new];
    line5.backgroundColor = KHEXCOLOR(@"#E0E0E0");
    
    [self.view addSubview:line5];
    [line5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(SCALAE_WIDTH(34.f));
        make.right.equalTo(self.view.mas_right).offset(SCALAE_WIDTH(-34.f));
        make.top.equalTo(self.inviteTF.mas_bottom);
        make.height.offset(0.5f);
    }];
    
    [_rgeisterBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(SCALAE_WIDTH(34.f));
        make.top.equalTo(line5.mas_bottom).offset(31.f);
        make.right.equalTo(self.view.mas_right).offset(SCALAE_WIDTH(-34.f));
        make.height.offset(40.f);
    }];
    
    
}


#pragma mark -- UITextFiledDelegate
- (void)passwardTFStrChange:(UITextField *)textFiled{
    NSLog(@"%@",textFiled.text);
}
//账号
- (void)accountTFStrChange:(UITextField *)textFiled{
    NSLog(@"%@",textFiled.text);
}

//输入昵称
- (void)nickNameTFStrChange:(UITextField *)textFiled{
    NSLog(@"%@",textFiled.text);
}

//再次输入密码
- (void)againPasswordStrChange:(UITextField *)textFiled{
    NSLog(@"%@",textFiled.text);
}

//限制输入框的长度
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string

{
    
    if (range.length + range.location > textField.text.length) {
        
        return NO;
        
    }
    NSUInteger length = textField.text.length + string.length - range.length;
    if (textField.tag == 101) {
        return length <= 10;
    }else if (textField.tag == 102 || textField.tag == 103){
        return length <= 20;
    }else{
           return length <= 6;
    }
  
}


//登录
- (void)rgeisterTouch:(UIButton *)sender{
    NSLog(@"注册");

    if ([NSObject ldy_isEmpty:_nickNameTF.text]) {
//        [self showTipHudWithText:@"昵称不能为空"];
         [MBProgressHUD showError:@"昵称未填写" afterDelay:3];
        return;
    }
    if ([NSObject ldy_isEmpty:_isMan] ||[_isMan isEqualToString:@"2"]) {
//        [self showTipHudWithText:@"性别未选择"];
         [MBProgressHUD showError:@"性别未选择" afterDelay:3];
        return;
    }
    if ([NSObject ldy_isEmpty:_accountTF.text]) {

         [MBProgressHUD showError:@"用户名未填写" afterDelay:3];
        return;
    }
    if (_accountTF.text.length<6) {
        [MBProgressHUD showError:@"用户名长度必须大于6位" afterDelay:3];
               return;
    }
    if (![CommonTools checkIsHaveNumAndLetter:_accountTF.text]) {
        [MBProgressHUD showError:@"用户名必须英文+数字、纯英文、纯数字" afterDelay:3];
               return;
    }
    if ([NSObject ldy_isEmpty:_passwordTF.text]||[NSObject ldy_isEmpty:_againPasswordTF.text]) {

         [MBProgressHUD showError:@"密码未填写" afterDelay:3];
        return;
    }
        if (_passwordTF.text.length <6) {
   
             [MBProgressHUD showError:@"密码必须大于6位" afterDelay:3];
            return;
        }
    if (![CommonTools checkIsHaveNumAndLetter:_passwordTF.text]) {
        [MBProgressHUD showError:@"请输入6-20位英文字母或者数字的密码" afterDelay:3];
               return;
    }
    if (![_passwordTF.text isEqualToString:_againPasswordTF.text]) {

         [MBProgressHUD showError:@"注册失败，密码不一致" afterDelay:3];
        return;
    }

    [LoginRequestLogic UserRigisterWithHead:_imageStr nickname:_nickNameTF.text password:_passwordTF.text sex:_isMan username:_accountTF.text invitationCode:@"" userUUid:[GetUUID getUUID] Success:^(NSDictionary * _Nonnull Dict) {
        AAIMLog(@"注册数据-%@",Dict);
        NSLog(@"%@",Dict[@"message"]);
        if ([Dict[@"code"] integerValue] == 200) {
            [self showTipHudWithText:Dict[@"message"]];

            KWeakSelf;
            if (self.RegiserAccountBlock) {
                self.RegiserAccountBlock(weakSelf.accountTF.text);
            }
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                        [self.navigationController popViewControllerAnimated:YES];
            });

        }else{
            [self showTipHudWithText:Dict[@"message"]];
        }
    } failure:^(NSString * _Nonnull errMsg) {
        [self showTipHudWithText:errMsg];
    }];


}

- (void)choosePictrue:(UITapGestureRecognizer *)tap{
//    UIAlertControllerStyleAlert
    UIAlertController * alerController = [UIAlertController alertControllerWithTitle:@"" message:@"上传头像图片" preferredStyle:UIAlertControllerStyleActionSheet];
    
    UIAlertAction * cancle = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    
    UIAlertAction * camera = [UIAlertAction actionWithTitle:@"相机" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [self openCamera];
    }];
   
    UIAlertAction * photo = [UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [self openPhotoLibrary];
    }];
    
    [alerController addAction:camera];
    [alerController addAction:photo];
    [alerController addAction:cancle];
    
    [self presentViewController:alerController animated:YES completion:nil];
   
}

/*** 调用照相机 */
- (void)openCamera{
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsEditing = YES; //可编辑
    //判断是否可以打开照相机
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
        //摄像头
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
        [self presentViewController:picker animated:YES completion:nil];
    }else{
        NSLog(@"没有摄像头");
        [self showTipHudWithText:@"打开相机失败"];
    }
}
/*** 打开相册  */
-(void)openPhotoLibrary{
    // 进入相册
    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]){
        UIImagePickerController *imagePicker = [[UIImagePickerController alloc]init];
        imagePicker.allowsEditing = YES;
        imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        imagePicker.delegate = self;
        [self presentViewController:imagePicker animated:YES completion:^{
            NSLog(@"打开相册");
        }];
    }else{
        NSLog(@"不能打开相册");
          [self showTipHudWithText:@"打开相册失败"];
    }
}

#pragma mark - UIImagePickerControllerDelegate
// 拍照完成回调
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey, id> *)info{
//    UIImage *image = info[@"UIImagePickerControllerOriginalImage"];
    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
//    NSLog(@"finish..");
    if(picker.sourceType == UIImagePickerControllerSourceTypeCamera){
        //图片存入相册
        _userHeaderImageView.image = image;
        UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
    }
    if(picker.sourceType == UIImagePickerControllerSourceTypePhotoLibrary){
        _userHeaderImageView.image = image;
    }
    
    [LoginRequestLogic getTempTokenSuccess:^(NSDictionary * _Nonnull Dict) {
    
        if ([Dict[@"code"] integerValue] == 200) {
             [self upLoadHeaderImage:image withToken:Dict[@"data"][@"lsToken"]];
//            NSLog(@"临时token：%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"TemToken"]);
        }
        
    } failure:^(NSString * _Nonnull errMsg) {
        
    }];
   

    [self dismissViewControllerAnimated:YES completion:nil];
}

-(void)getTemToken{
   [LoginRequestLogic getTempTokenSuccess:^(NSDictionary * _Nonnull Dict) {
       KWeakSelf;
        if ([Dict[@"code"] integerValue] == 200) {
            weakSelf.temToken = Dict[@"data"][@"lsToken"];
        }
        
    } failure:^(NSString * _Nonnull errMsg) {
        
    }];
}


//上传头像
- (void)upLoadHeaderImage:(UIImage *)image withToken:(NSString *)token{
    [LoginRequestLogic upLoadFile:image withToken:token Success:^(NSDictionary * _Nonnull Dict) {
        NSLog(@"134567890-----%@",Dict);
        KWeakSelf;
        if ([Dict[@"code"] integerValue] == 200) {
            weakSelf.imageStr = Dict[@"data"];
        }
    } failure:^(NSString * _Nonnull errMsg) {
        NSLog(@"出错了：%@",errMsg);
    }];
}
//进入拍摄页面点击取消按钮
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
    [self dismissViewControllerAnimated:YES completion:nil];
}


//邀请码
- (void)inviteCodeTFStrChange:(UITextField *)textFiled{
    NSLog(@"邀请码");
}


- (void)setWoManActive:(UIButton *)sender{
    sender.selected = !sender.selected;
    if (sender.selected) {
        [sender setImage:[UIImage imageNamed:@"选中状态-女"] forState:UIControlStateNormal];
        _sexManBtn.selected = NO;
        _isMan = @"1";
        [_sexManBtn setImage:[UIImage imageNamed:@"未选中状态-男"] forState:UIControlStateNormal];
    }else{
        [sender setImage:[UIImage imageNamed:@"未选中状态-女"] forState:UIControlStateNormal];
        _isMan = @"2";
    }
}

- (void)setManActive:(UIButton *)sender{
    sender.selected = !sender.selected;
    if (sender.selected) {
         [sender setImage:[UIImage imageNamed:@"选中状态-男"] forState:UIControlStateNormal];
        _sexWomanBnt.selected = NO;
        _isMan = @"0";
        [_sexWomanBnt setImage:[UIImage imageNamed:@"未选中状态-女"] forState:UIControlStateNormal];
    }else{
        [sender setImage:[UIImage imageNamed:@"未选中状态-男"] forState:UIControlStateNormal];
        _isMan = @"2";
    }
}


//- (UIButton *)backBtn{
//    if (!_backBtn) {
//        _backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//        [_backBtn setImage:[UIImage imageNamed:@"bar_back1"] forState:UIControlStateNormal];
//        [_backBtn addTarget:self action:@selector(BackActive:) forControlEvents:UIControlEventTouchUpInside];
//    }
//    return _backBtn;
//}


- (UIImageView *)userHeaderImageView{
    if (!_userHeaderImageView) {
        _userHeaderImageView = [[UIImageView alloc]init];
        _userHeaderImageView.image = [UIImage imageNamed:@"头像-选中"];
        _userHeaderImageView.userInteractionEnabled = YES;
        _userHeaderImageView.layer.masksToBounds = YES;
//        _userHeaderImageView.contentMode = UIViewContentModeScaleAspectFill;
        _userHeaderImageView.layer.cornerRadius = 49.f;
        UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(choosePictrue:)];
        tap.numberOfTapsRequired = 1;
        tap.numberOfTouchesRequired = 1;
        
        [_userHeaderImageView addGestureRecognizer:tap];
    }
    
    NSLog(@"%.2f",_userHeaderImageView.layer.cornerRadius);
    return _userHeaderImageView;
}

- (UILabel *)updataImage{
    if (!_updataImage) {
        _updataImage = [[UILabel alloc]init];
        _updataImage.text = @"上传头像";
        _updataImage.textColor = KHEXCOLOR(@"#AFAFAF");
        _updataImage.font = kMainFont(15);
        
    }
    return _updataImage;
}

- (UITextField *)nickNameTF{
    if (!_nickNameTF) {
        _nickNameTF = [[UITextField alloc]init];
        _nickNameTF.placeholder = @"请输入昵称";
        _nickNameTF.font = kMainFont(15);
        _nickNameTF.delegate =self;
        _nickNameTF.tag = 101;
        _nickNameTF.textColor = KHEXCOLOR(@"#262B2F");
        _nickNameTF.borderStyle = UITextBorderStyleNone;
        [_nickNameTF addTarget:self action:@selector(nickNameTFStrChange:) forControlEvents:UIControlEventEditingChanged];
    }
    return _nickNameTF;
}

-(UIButton *)sexManBtn{
    if (!_sexManBtn) {
        _sexManBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_sexManBtn setTitle:@"男" forState:UIControlStateNormal];
        [_sexManBtn setImage:[UIImage imageNamed:@"未选中状态-男"] forState:UIControlStateNormal];
        [_sexManBtn setBackgroundColor:KHEXCOLOR(@"#FFFFFF")];
        [_sexManBtn setTitleColor:KHEXCOLOR(@"#AFAFAF") forState:UIControlStateNormal];
        [_sexManBtn addTarget:self action:@selector(setManActive:) forControlEvents:UIControlEventTouchUpInside];
        [_sexManBtn.titleLabel setFont:kMainFont(15)];
        [_sexManBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 8.f, 0, -8.f)];
    }
    return _sexManBtn;
    
}

-(UIButton *)sexWomanBnt{
    if (!_sexWomanBnt) {
        _sexWomanBnt = [UIButton buttonWithType:UIButtonTypeCustom];
        [_sexWomanBnt setTitle:@"女" forState:UIControlStateNormal];
        [_sexWomanBnt setImage:[UIImage imageNamed:@"未选中状态-女"] forState:UIControlStateNormal];
        [_sexWomanBnt setBackgroundColor:KHEXCOLOR(@"#FFFFFF")];
        [_sexWomanBnt setTitleColor:KHEXCOLOR(@"#AFAFAF") forState:UIControlStateNormal];
        [_sexWomanBnt addTarget:self action:@selector(setWoManActive:) forControlEvents:UIControlEventTouchUpInside];
        [_sexWomanBnt.titleLabel setFont:kMainFont(15)];
        [_sexWomanBnt setTitleEdgeInsets:UIEdgeInsetsMake(0, 8.f, 0, -8.f)];
    }
    return _sexWomanBnt;
    
}


- (UITextField *)againPasswordTF{
    if (!_againPasswordTF) {
        _againPasswordTF = [[UITextField alloc]init];
        _againPasswordTF.placeholder = @"请再次输入密码";
        _againPasswordTF.font = kMainFont(15);
        _againPasswordTF.delegate =self;
        _againPasswordTF.tag= 103;
        _againPasswordTF.textColor = KHEXCOLOR(@"#262B2F");
        _againPasswordTF.borderStyle = UITextBorderStyleNone;
        _againPasswordTF.secureTextEntry = YES;
        [_againPasswordTF addTarget:self action:@selector(againPasswordStrChange:) forControlEvents:UIControlEventEditingChanged];
    }
    return _againPasswordTF;
}


- (UITextField *)inviteTF{
    if (!_inviteTF) {
        _inviteTF = [[UITextField alloc]init];
        _inviteTF.placeholder = @"请输入邀请码（选填）";
        _inviteTF.font = kMainFont(15);
        _inviteTF.delegate =self;
        _inviteTF.tag = 104;
        _inviteTF.textColor = KHEXCOLOR(@"#262B2F");
        _inviteTF.borderStyle = UITextBorderStyleNone;
        [_inviteTF addTarget:self action:@selector(inviteCodeTFStrChange:) forControlEvents:UIControlEventEditingChanged];
    }
    return _inviteTF;
}


- (UITextField *)accountTF{
    if (!_accountTF) {
        _accountTF = [[UITextField alloc]init];
        _accountTF.placeholder = @"请输入您的用户名/邮箱/手机号";
        _accountTF.font = kMainFont(15);
        _accountTF.delegate =self;
        _accountTF.tag = 102;
        _accountTF.textColor = KHEXCOLOR(@"#262B2F");
        _accountTF.borderStyle = UITextBorderStyleNone;
        [_accountTF addTarget:self action:@selector(accountTFStrChange:) forControlEvents:UIControlEventEditingChanged];
    }
    return _accountTF;
}

- (UITextField *)passwordTF{
    if (!_passwordTF) {
        _passwordTF = [[UITextField alloc]init];
        _passwordTF.placeholder = @"6-20位英文字母或者数字";
        _passwordTF.font = kMainFont(15);
        _passwordTF.delegate =self;
        _passwordTF.tag = 103;
        _passwordTF.textColor = KHEXCOLOR(@"#262B2F");
        _passwordTF.borderStyle = UITextBorderStyleNone;
        _passwordTF.secureTextEntry = YES;
        [_passwordTF addTarget:self action:@selector(passwardTFStrChange:) forControlEvents:UIControlEventEditingChanged];
    }
    return _passwordTF;
}

-(UIButton *)rgeisterBtn{
    if (!_rgeisterBtn) {
        _rgeisterBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_rgeisterBtn setTitle:@"完成注册" forState:UIControlStateNormal];
        [_rgeisterBtn setBackgroundColor:KHEXCOLOR(@"#4795EF")];
        _rgeisterBtn.layer.cornerRadius = 5.0f;
        _rgeisterBtn.layer.masksToBounds = YES;
        [_rgeisterBtn setTitleColor:KHEXCOLOR(@"#ffffff") forState:UIControlStateNormal];
        [_rgeisterBtn addTarget:self action:@selector(rgeisterTouch:) forControlEvents:UIControlEventTouchUpInside];
        [_rgeisterBtn.titleLabel setFont:kMainFont(15)];
    }
    return _rgeisterBtn;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
